package net.ocps.tchs.GovSim;

import java.util.Scanner;


public class TextVersionGovSim {

	/**
	 * Hayden Mashburn
	 * Text Version of GovSim, to test the logic behind the game
	 */
	public static void main(String[] args) {
		long millis=System.currentTimeMillis(); //Current time
		long millisPassed=0; // Time passed between counting
		long lastMillis=System.currentTimeMillis();
		long totalMillisPassed=0;
		long lastEvent=0;
		int upgradePoints=0;
		double money=100;
		double economy=50;
		double rep=60;
		double control=30;
		int input;
		boolean randomEvent=false;
		Scanner scan = new Scanner(System.in);
		boolean game = true;
		boolean inWar=false;

		System.out.println("Game Version: 1 or 2");
		int vers = scan.nextInt();
		if (vers==1){
			int turn=0;
			while (game){
				turn++;
				if (turn==1){
					System.out.println("The Cold War has started; 1- Threaten 2-Ignore");
					input=scan.nextInt();
					if (input==1){
						rep+=20;
						economy-=10;
					}
					else if(input==2){
						economy+=5;
					}
				}
				else if(turn==2){
					System.out.println("Embargo commuist allies or trade? 1-Embargo 2-Trade");
					input=scan.nextInt();
					if (input==1){
						if (rep>=70){
							System.out.println("They comply");
							control+=10;
							economy-=5;
							money-=10;
						}
						else {
							System.out.println("Your attempts scare no-one.");
							economy-=30;
							control-=10;
						}
					}
					else if(input==2){
						if (rep>=70){
							System.out.println("The Soviets increase control and threaten your trades");
							control-=10;
							economy-=20;

						}
						else {
							System.out.println("Trade continues normally; both parties gain benefits");
							economy+=20;
						}
					}

				}

				else if(turn==3){
					System.out.println("");
					input=scan.nextInt();
					if (input==1){

					}
					else if(input==2){

					}
				}

				else if(turn==4){
					System.out.println("");
					input=scan.nextInt();
					if (input==1){

					}
					else if(input==2){

					}
				}
			}
		}
		else if(vers==2){
			while (game){
				System.out.println("1: Print Status \n2: More info");
				input=scan.nextInt();
				millis=System.currentTimeMillis(); //Current time
				millisPassed = (millis-lastMillis); //How much time has passed between checks
				money=(int) (money+(economy*millisPassed)/100);
				totalMillisPassed+=millisPassed;
				lastMillis=millis;// Last count

				if ((totalMillisPassed-lastEvent)>=10000){//Random event current interval: 10 sec
					randomEvent=true;
					lastEvent=totalMillisPassed;
					int eventNum= (int)(2*Math.random());
					if (eventNum==0){
						System.out.println("1 Start war 2 Try for peace");
						int input0=scan.nextInt();
						if (input0==1){
							money=money*0.8;
							rep=rep+20;
							economy=economy-20;
							inWar=true;
						}
						else if(input0==2){
							rep+=10;

						}
					}
					else if (eventNum==1){
						System.out.println("You're been invaded 1 War 2 Peace");
					}

				}
				if (input==1){
					//System.out.println("millis: "+millis);
					System.out.println("millisPassed "+millisPassed);
					System.out.println("Money: "+money);

					//System.out.println("");				
				}
				else if(input==2){
					System.out.println("Economy: "+economy);
					System.out.println("Reputation: "+rep);
					System.out.println("inWar: "+inWar);
					System.out.println("Upgrade Points: "+upgradePoints);
				}
				if (!inWar){

				}
				else if (inWar){

				}
			}
		}


	}

}
